// 防抖
function debounce(fn,time){
    let timer = null
    return function(e){
        clearTimeout(timer)
        timer = setTimeout(()=>{
            fn.call(this,e)
        },time) 
    }
}

// 节流
function throttle(fn,time){
    let listTime = 0
    return function(e){
        let newTime = Date.now()
        if(newTime-listTime<time){
            return
        }
        listTime = newTime,
        fn.call(this,e)
    }
}

// 深拷贝
const obj = {
    name:"zhangsan",
    zge:11
}
function deepCode(obj){
    const obj2 = Object.prototype.toString.call(obj) === "[Object Array]"? [] : {}
    for(var key in obj){
        if(obj.hasOwnProperty){
            if(typeof obj[key] === "object"){
                obj2[key] = deepCode(obj[key])
            }else{
                obj2[key] = obj[key]
            }
        }
        return obj2
    }
}

const o = deepCode(obj)
o.age = 20
console.log(obj)
console.log(o)